//
//  NInovationCommonViewController.m
//  nncloud
//
//  Created by macfai on 2018/11/21.
//  Copyright © 2018 macfai. All rights reserved.
//

//

#import "NInovationCommonViewController.h"
#import "NInoCommonModel.h"
#import "NShuangChuangDetailVC.h"
@interface NInovationCommonViewController ()<UITableViewDataSource,UITableViewDelegate>

@property (nonatomic,strong)UITableView *tableView;

@property (nonatomic,strong)NSMutableArray *dataArray;


@end
#define cellIdentifier  @"feedbackid"
#define HeaderHight  290
#define PageSize 20
@implementation NInovationCommonViewController

-(UITableView *)tableView{
    
    if (!_tableView) {
        
        WeakStament(ws);
        _tableView = [[UITableView alloc] initWithFrame:CGRectMake(0 , 0, ScreenWidth , ScreenHeight - 64) style:UITableViewStylePlain];
        _tableView.delegate = self;
        _tableView.dataSource = self;
        _tableView.rowHeight = 80.f;
        //        _tableView.separatorColor = [UIColor clearColor];
        _tableView.backgroundColor = kBackgroundColor;
        [_tableView registerNib:[UINib nibWithNibName:@"NFeedbackCell" bundle:nil] forCellReuseIdentifier:cellIdentifier];
//        _tableView.mj_header = [MJRefreshNormalHeader headerWithRefreshingBlock:^{
//                        [ws loadData];
//        }];
        //        _tableView.mj_footer = [MJRefreshAutoNormalFooter footerWithRefreshingBlock:^{
        //            [ws loadMoreData];
        //        }];
        _tableView.showsVerticalScrollIndicator = NO;
        _tableView.tableFooterView = [UIView new];
        
    }
    return _tableView;
}






- (void)viewDidLoad {
    
    [super viewDidLoad];
    
    self.view.backgroundColor = kWhiteColor;
    
    if (self.atitle) {
        
        [self.navigationItem setItemWithTitle:self.atitle textColor:kNavigationTitleColor fontSize:18 itemType:center];
    }
    self.dataArray = [NSMutableArray array];
    
    [self.view addSubview:self.tableView];
    [self loadData];
    
    // Do any additional setup after loading the view from its nib.
}

- (void)loadData
{
    NSMutableArray *arr;
    
    if ([self.atitle isEqualToString:@"智慧招商"]) {
        arr = [self getArray1];
    }else if ([self.atitle isEqualToString:@"创新创业"]){
        arr = [self getArray2];
    }else if ([self.atitle isEqualToString:@"知识产权"]){
        arr = [self getArray3];
    }else if ([self.atitle isEqualToString:@"项目申报"]){
        arr = [self getArray4];
    }else if ([self.atitle isEqualToString:@"培训服务"]){
        arr = [self getArray5];
    }else if ([self.atitle isEqualToString:@"融资服务"]){
        arr = [self getArray6];
    }else if ([self.atitle isEqualToString:@"项目路演"]){
        arr = [self getArray7];
    }
    
    for (NSDictionary *dic in arr) {
        NInoCommonModel *model = [NInoCommonModel new];
        [model setValuesForKeysWithDictionary:dic];
        [self.dataArray addObject:model];
    }
    [self.tableView reloadData];
}

#pragma mark - delegate datasource

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    
    NShuangChuangDetailVC *sc = [NShuangChuangDetailVC new];
    if ([self.atitle isEqualToString:@"智慧招商"]) {
        
        if (indexPath.row==0) {
            sc.url = @"http://cdyoue.com.cn:18180/h5/html/cxcy/zhzs/nnfgjmgy.html";
        }else if (indexPath.row==1){
            sc.url = @"http://cdyoue.com.cn:18180/h5/html/cxcy/zhzs/gxtyshgf.html";
        }else{
            sc.url = @"http://cdyoue.com.cn:18180/h5/html/cxcy/zhzs/deprz.html";
        }
        
    }else if ([self.atitle isEqualToString:@"创新创业"]){
        if (indexPath.row==0) {
            sc.url = @"http://cdyoue.com.cn:18180/h5/html/cxcy/cxcyxm/ymjykh.html";
        }else if (indexPath.row==1){
            sc.url = @"http://cdyoue.com.cn:18180/h5/html/cxcy/cxcyxm/2017nnns.html";
        }else{
            
            sc.url = @"http://cdyoue.com.cn:18180/h5/html/cxcy/cxcyxm/szhgl.html";
        }
    }else if ([self.atitle isEqualToString:@"知识产权"]){
        if (indexPath.row==0) {
            sc.url = @"http://cdyoue.com.cn:18180/h5/html/cxcy/zscq/gxgp.html";
        }else if (indexPath.row==1){
            sc.url = @"http://cdyoue.com.cn:18180/h5/html/cxcy/zscq/qjmd.html";
        }
    }else if ([self.atitle isEqualToString:@"项目申报"]){
        if (indexPath.row==0) {
            
            sc.url = @"http://cdyoue.com.cn:18180/h5/html/cxcy/xmsq/gykzdsjnns.html";
        }else if (indexPath.row==1){
            sc.url = @"http://cdyoue.com.cn:18180/h5/html/cxcy/xmsq/gyzzsbnns.html";
        }
    }else if ([self.atitle isEqualToString:@"培训服务"]){
        
        if (indexPath.row==0) {
            sc.url = @"http://cdyoue.com.cn:18180/h5/html/cxcy/pxfw/zcswly.html";
        }else if (indexPath.row==1){
            sc.url = @"http://cdyoue.com.cn:18180/h5/html/cxcy/pxfw/gxkxy.html";
        }else{
            
            sc.url = @"http://cdyoue.com.cn:18180/h5/html/cxcy/pxfw/zxqyjxkh.html";
        }
    }else if ([self.atitle isEqualToString:@"融资服务"]){
        
        if (indexPath.row==0) {
            sc.url = @"http://cdyoue.com.cn:18180/h5/html/cxcy/rzfw/nn--2018nd2q.html";
        }else if (indexPath.row==1){
        
            sc.url = @"http://cdyoue.com.cn:18180/h5/html/cxcy/rzfw/gxtltz.html";
        }
        
    }else if ([self.atitle isEqualToString:@"项目路演"]){
        
        //ok
        if (indexPath.row==0) {
            sc.url = @"http://cdyoue.com.cn:18180/h5/html/cxcy/xmly/zlqyrz.html";
        }else if (indexPath.row==1){
            sc.url = @"http://cdyoue.com.cn:18180/h5/html/cxcy/xmly/nnxj--2018nd3q.html";
        }else{
            sc.url = @"http://cdyoue.com.cn:18180/h5/html/cxcy/xmly/nnxj--2018nd4q.html";
        }
    }
    [self.navigationController pushViewController:sc animated:YES];
    
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return self.dataArray.count;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    
    NFeedbackCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier forIndexPath:indexPath];
    
    NInoCommonModel *model  = self.dataArray[indexPath.row];
    
    cell.nameLabel.text = model.nameTitle;
    
    //在这里timelabel 是detail的显示
    cell.timeLabel.text = model.detail;
    //这个用来显示时间
    cell.stateLabel.text = model.time;
    cell.stateLabel.textColor = kLightGrayColor;
    cell.bottomMargin.constant = 13.f;
    cell.tipLabel.hidden = YES;
//    NFeedbackModel *model = self.dataArray[indexPath.row];
//    if (self.dataArray.count>indexPath.row) {
//                [cell configWithData:model];
//                YYLog(@"%@",);cell.model
//    }
    return cell;
}


///智慧招商
- (NSMutableArray *)getArray1 {
    
    NSMutableArray *array = [NSMutableArray array];
    
    NSDictionary *dic0 = @{@"nameTitle":@"南宁富桂精密工业有限公司",@"detail":@"优企推荐",@"time":@"2018-11-11",};
    
    NSDictionary *dic1 = @{@"nameTitle":@"广西田园生化股份有限公司",@"detail":@"优企推荐",@"time":@"2018-11-11",};
    
    NSDictionary *dic2 = @{@"nameTitle":@"第二批入驻创业项目公示",@"detail":@"孵化公示",@"time":@"2018-11-11",};
    
    [array addObject:dic0];
    [array addObject:dic1];
    [array addObject:dic2];
    return array;
}

///创新创业
- (NSMutableArray *)getArray2 {
    
    NSMutableArray *array = [NSMutableArray array];
    NSDictionary *dic0 = @{@"nameTitle":@"玉米集雨抗旱早播覆膜技术",@"detail":@"成果推广",@"time":@"2018-11-11",};
    NSDictionary *dic1 = @{@"nameTitle":@"2017年南宁市大数据应用与安全技术交流暨科技成果发布会成功举行",@"detail":@"成果转化",@"time":@"2018-11-11",};
    NSDictionary *dic2 = @{@"nameTitle":@"数字化管理技术—产品数据管理系统(PDM)",@"detail":@"孵技术前沿",@"time":@"2018-11-11",};
    [array addObject:dic0];
    [array addObject:dic1];
    [array addObject:dic2];
    return array;
}
///知识产权
- (NSMutableArray *)getArray3 {
    

    NSMutableArray *array = [NSMutableArray array];
    NSDictionary *dic0 = @{@"nameTitle":@"高效广谱无公害细菌杀虫剂",@"detail":@"专利产品库",@"time":@"2018-11-11",};
    NSDictionary *dic1 = @{@"nameTitle":@"羟基嘧啶的绿色生产工艺",@"detail":@"专利产品库",@"time":@"2018-11-11",};
//    NSDictionary *dic2 = @{@"nameTitle":@"一种动力装置",@"detail":@"201520084684.8",@"time":@"F16H37/12",};
    [array addObject:dic0];
    [array addObject:dic1];
//    [array addObject:dic2];
    return array;
}
///项目申报
- (NSMutableArray *)getArray4 {
    
    NSMutableArray *array = [NSMutableArray array];
    NSDictionary *dic0 = @{@"nameTitle":@"关于开展第三届南宁市市长质量奖申报工作的通知",@"detail":@"项目申报",@"time":@"2018-11-11",};
    NSDictionary *dic1 = @{@"nameTitle":@"关于组织申报南宁市2018年 租赁工业标准厂房财政不住资金计划的通知",@"detail":@"政策公示",@"time":@"2018-11-11",};
    //    NSDictionary *dic2 = @{@"nameTitle":@"一种动力装置",@"detail":@"201520084684.8",@"time":@"2018-11-11",};
    [array addObject:dic0];
    [array addObject:dic1];
    //    [array addObject:dic2];
    return array;
}
///培训服务
- (NSMutableArray *)getArray5 {
    
    NSMutableArray *array = [NSMutableArray array];
    NSDictionary *dic0 = @{@"nameTitle":@"职场商务礼仪培训",@"detail":@"培训公告",@"time":@"2018-11-11",};
    NSDictionary *dic1 = @{@"nameTitle":@"广西科学院签订产学研合作协议",@"detail":@"产学研合作",@"time":@"2018-11-11",};
    NSDictionary *dic2 = @{@"nameTitle":@"《中小企业绩效考核》实战训练营",@"detail":@"课程推荐",@"time":@"2018-11-11",};
    [array addObject:dic0];
    [array addObject:dic1];
    [array addObject:dic2];
    return array;
}


///融资
- (NSMutableArray *)getArray6 {
    
    NSMutableArray *array = [NSMutableArray array];
    
    NSDictionary *dic0 = @{@"nameTitle":@"南宁先进技术育成中心举办2018年第2期 (总第7期)项目路演推介会",@"detail":@"金融资讯",@"time":@"2018-11-11",};
    
    NSDictionary *dic1 = @{@"nameTitle":@"广西铁路投资集团筹融资新增近百亿元　铁路建设项目推进",@"detail":@"优融资案例",@"time":@"2018-11-11",};
    
//    NSDictionary *dic2 = @{@"nameTitle":@"第二批入驻创业项目公示",@"detail":@"孵化公示",@"time":@"2018-11-11",};
    
    [array addObject:dic0];
    [array addObject:dic1];
//    [array addObject:dic2];
    return array;
}

///路演
- (NSMutableArray *)getArray7 {
    
    NSMutableArray *array = [NSMutableArray array];
    NSDictionary *dic0 = @{@"nameTitle":@"助力企业融资，让创新创业远航",@"detail":@"项目路演会",@"time":@"2018-11-11",};
    NSDictionary *dic1 = @{@"nameTitle":@"南宁先进技术育成中心举办2018年第3期",@"detail":@"项目路演会",@"time":@"2018-11-11",};
    NSDictionary *dic2 = @{@"nameTitle":@"南宁先进技术育成中心2018年第4期（总第9期)",@"detail":@"项目路演会",@"time":@"2018-11-11",};
    [array addObject:dic0];
    [array addObject:dic1];
    [array addObject:dic2];
    return array;
}

@end
